sortlistmodel: Fix a crash
authorMatthias Clasen <mclasen@redhat.com>
Fri, 24 Jul 2020 14:40:55 +0000 (10:40 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 24 Jul 2020 18:15:14 +0000 (14:15 -0400)
gtk/gtksortlistmodel.c

index f79bb77a1e476437eb6e3ea8c02fd0622fdb3cba..64bd038bccddebcdbedcf46fc3c7da958d1f178a 100644 (file)
@@ -148,6 +148,9 @@ gtk_sort_list_model_get_item (GListModel *list,
   if (self->model == NULL)
     return NULL;
 
+  if (position >= self->n_items)
+    return NULL;
+
   if (self->positions)
     position = pos_from_key (self, self->positions[position]);